package com.stx.action;

import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import com.opensymphony.xwork2.ActionSupport;
import com.stx.entity.Film;
import com.stx.entity.Film_comment;
import com.stx.entity.User;
import com.stx.service.FilmService;
import com.stx.service.UserService;

public class GetFilm extends ActionSupport {

	private Film film;
	private FilmService fs;
	private String film_releasetime;
	private Set<Film_comment>film_comment_set;
	
		
	public Set<Film_comment> getFilm_comment_set() {
		return film_comment_set;
	}
	public void setFilm_comment_set(Set<Film_comment> film_comment_set) {
		this.film_comment_set = film_comment_set;
	}
	public String getFilm_releasetime() {
		return film_releasetime;
	}
	public void setFilm_releasetime(String film_releasetime) {
		this.film_releasetime = film_releasetime;
	}
	public Film getFilm() {
		return film;
	}
	public void setFilm(Film film) {
		this.film = film;
	}
	public FilmService getFs() {
		return fs;
	}
	public void setFs(FilmService fs) {
		this.fs = fs;
	}
	
	/*
	 * 得到具体的电影信息
	 * 修改下上映时间的格式
	 * */
	public String findFilmInformation(){
		if(film==null){
			return "error";
		}
		film=fs.getFilm(film);
		if(film!=null){
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		film_releasetime=sdf.format(film.getFi_releasetime());
		System.out.println("电影信息获取成功"+film_releasetime);
		/*
		 * 测试是否能得到评论列表
		 * */
		film_comment_set=film.getFilm_comment();
		Iterator<Film_comment> iterator=film.getFilm_comment().iterator();
		User user=new User();
		Film_comment fc=new Film_comment();
		while(iterator.hasNext()){
			fc=iterator.next();
			System.out.println(fc.getSc_countent());
			System.out.println(fc.getUser().getUs_nickname());
		}
		return "success";
		}else{
		 return "error";
		}
		}
}
